import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;

@Data
public class Torrent {
    /*资源唯一标识符*/
    Integer index;
    /*Tracker地址*/
    Address trackerAddress;
    /*文件名*/
    String name;
    /*文件长度,以字节为单位*/
    Integer length;
    /*块的长度,以字节为单位*/
    Integer piecesLength = 20480;//81920/4;
    /*每个数据块Hash值*/
    ArrayList<Integer> pieces;

    /*种子提供者生成.torrent文件*/
    public Torrent(String fileName, Address trackerAddress) {
        setTrackerAddress(trackerAddress);
        getFileInfo(fileName);
    }
    public Torrent(String torrent) {
    }

    public String toString() {
        String string = "";

        return string;
    }
    public Torrent(){};

    /*读取文件得到文件信息*/
    public void getFileInfo(String fileName) {
        setName(fileName.substring(fileName.lastIndexOf("\\")+1));
    }

}
